package cn.tedu.boyou.mgrsite.controller;

import cn.tedu.boyou.acticle.domain.Festival;
import cn.tedu.boyou.acticle.service.IDestinationService;
import cn.tedu.boyou.acticle.service.IFestivalService;
import cn.tedu.boyou.common.query.DestinationQuery;
import cn.tedu.boyou.common.query.QueryObject;
import cn.tedu.boyou.common.util.AjaxResult;
import com.alibaba.dubbo.config.annotation.Reference;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 目的地
 */
@Controller
@RequestMapping("/festival")
public class FestivalController {

    @Reference
    private IFestivalService festivalService;

    @RequestMapping("/list")
    public String list(Model model, @ModelAttribute("qo")QueryObject qo){
        PageInfo pageInfo = festivalService.query(qo);
        model.addAttribute("pageInfo",pageInfo);
        return "festival/list";
    }

    @RequestMapping("/saveOrUpdate")
    @ResponseBody
    public AjaxResult saveOrUpdate(Festival festival){
        festivalService.saveOrUpdate(festival);
        return new AjaxResult();
    }

    @RequestMapping("/changeStateValue")
    @ResponseBody
    public AjaxResult changeStateValue(Festival festival){
        festivalService.changeStateValueById(festival);
        return new AjaxResult();
    }

}
